<template>
  <!--采购申请-->
  <div style="padding: 20px">
    <el-card class="box-card">
      <el-tabs v-model="activeName" @tab-click="handleClick">
        <el-tab-pane label="全部" name="first"><el-button @click="handleNew">新增</el-button>
          <el-button @click="handleDelete">删除</el-button>
          <el-input placeholder="请输入设备编号或名称" clearable prefix-icon="el-icon-search" suffix-icon="el-icon-s-cale"
            style="width: 250px; margin-left: 660px" />
          <el-popover placement="right" width="400" trigger="click">
            <svg-icon icon-class="caiss" style="width: 40px; height: 20px" class="pointer" slot="reference" />
          </el-popover>
          <el-table :data="filteredData" style="width: 100%; margin-top: 20px" header-align="center" align="center">
            <el-table-column type="selection" width="55" fixed align="center" />
            <el-table-column prop="序号" label="序号" width="70" fixed />
            <el-table-column label="操作" width="80" fixed>
              <template v-slot="scope">
                <el-button type="text" @click="handleView(scope.row)">查看</el-button>
              </template>
            </el-table-column>
            <el-table-column prop="状态" label="状态" width="80" />
            <el-table-column prop="申请单号" label="申请单号" width="200" align="center" />
            <el-table-column prop="申请主题" label="申请主题" width="200" align="center" />
            <el-table-column prop="申请时间" label="申请时间" width="180" align="center" />
            <el-table-column prop="申请人" label="申请人" width="100" align="center" />
            <el-table-column prop="申请部门" label="申请部门" width="100" align="center" />
            <el-table-column prop="联系方式" label="联系方式" width="200" align="center" />
            <el-table-column prop="申请事由" label="申请事由" width="200" align="center" />
            <el-table-column prop="申请采购数量" label="申请采购数量" width="100" />
            <el-table-column prop="预计总金额" label="预计总金额" width="100" />
            <el-table-column prop="备注" label="备注" width="200" />
          </el-table>

          <el-pagination background style="margin-top: 20px; text-align: right" :page-size="10" :total="45"
            layout="prev, pager, next, sizes, total" :page-sizes="[10, 20, 30, 50]" /></el-tab-pane>
        <el-tab-pane label="我的申请" name="second">我的申请</el-tab-pane>
        <el-tab-pane label="我的审批" name="third">我的审批</el-tab-pane>
      </el-tabs>
    </el-card>
  </div>
</template>

<script>
export default {
  data() {
    return {
      //卡片信息
      activeName: "first",
      searchText: "",
      data: [
        {
          序号: 1,
          状态: "待审核",
          申请单号: "CGDH22111713202",
          申请主题: "数控机床采购申请表",
          申请时间: "2025-07-12",
          申请人: "许含娇",
          申请部门: "维修部门",
          联系方式: "18340411600",
          申请事由: "设备的老化，需求",
        },
        // 更多数据...
      ],
      currentPage: 1,
      pageSize: 10,
    };
  },
  computed: {
    filteredData() {
      return this.data
        .filter((item) => {
          return (
            item.申请单号.includes(this.searchText) ||
            item.申请主题.includes(this.searchText)
          );
        })
        .slice(
          (this.currentPage - 1) * this.pageSize,
          this.currentPage * this.pageSize
        );
    },
    total() {
      return this.data.length;
    },
  },
  methods: {
    //卡片选择信息
    handleClick(tab, event) {
      console.log("卡片", tab, event);
    },
    handleSearch() {
      this.currentPage = 1;
    },
    handleNew() {
      // 处理新增操作
      this.$router.push({ path: "/sb/yan/dang/xin" });
    },
    handleDelete() {
      // 处理删除操作
    },
    handleView(row) {
      // 查看具体信息
      this.$router.push({ path: "/sb/yan/dang/cha" });
    },
    handlePageChange(page) {
      this.currentPage = page;
    },
  },
};
</script>

<style>
/* 自定义样式 */
.text {
  font-size: 14px;
}

.item {
  padding: 18px 0;
}

.box-card {
  width: 1210px;
  height: 660px;
  margin-left: 14px;
}
</style>
